﻿using System;
using System.Xml;

namespace ShimmerConnect
{
    public static class xmlParse
    {
        public static string readString(XmlReader pXmlReader, string pTagString)
        {
            pXmlReader.ReadStartElement(pTagString);
            string xmlStr = pXmlReader.ReadString();
            pXmlReader.ReadEndElement();

            return xmlStr;
        }

        public static bool readBool(XmlReader pXmlReader, string pTagString)
        {
            pXmlReader.ReadStartElement(pTagString);
            bool xmlBool;

            if (pXmlReader.ReadString() == "False")
                xmlBool = false;
            else
                xmlBool = true;

            pXmlReader.ReadEndElement();

            return xmlBool;
        }

        public static int readInt(XmlReader pXmlReader, string pTagString)
        {
            pXmlReader.ReadStartElement(pTagString);
            int xmlInt = int.Parse(pXmlReader.ReadString());
            pXmlReader.ReadEndElement();

            return xmlInt;
        }

        public static float readFloat(XmlReader pXmlReader, string pTagString)
        {
            pXmlReader.ReadStartElement(pTagString);
            float xmlFloat = float.Parse(pXmlReader.ReadString());
            pXmlReader.ReadEndElement();

            return xmlFloat;
        }
    }
}
